package com.hyx.api.controller.pc_admin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hyx.api.domain.bo.CompanyRecoverInfoBo;
import com.hyx.api.domain.vo.CompanyRecoverInfoVo;
import com.hyx.api.service.pc_admin.ICompanyRecoverInfoService;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 公司回收商合作关联Controller
 *
 * @author ruoyi
 * @date 2023-10-25
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/info")
public class CompanyRecoverInfoController extends BaseController
{
    private final ICompanyRecoverInfoService companyRecoverInfoService;

    /**
     * 查询公司回收商合作关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyRecoverInfoBo bo)
    {
        startPage();
        List<CompanyRecoverInfoVo> list = companyRecoverInfoService.selectCompanyRecoverInfoList(bo);
        return getDataTable(list);
    }

    /**
     * 导出公司回收商合作关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "公司回收商合作关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompanyRecoverInfoBo bo)
    {
        List<CompanyRecoverInfoVo> list = companyRecoverInfoService.selectCompanyRecoverInfoList(bo);
        ExcelUtil<CompanyRecoverInfoVo> util = new ExcelUtil<>(CompanyRecoverInfoVo.class);
        util.exportExcel(response, list, "公司回收商合作关联数据");
    }

    /**
     * 获取公司回收商合作关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(companyRecoverInfoService.selectCompanyRecoverInfoById(id));
    }

    /**
     * 新增公司回收商合作关联
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "公司回收商合作关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody CompanyRecoverInfoBo bo)
    {
        return toAjax(companyRecoverInfoService.insertCompanyRecoverInfo(bo));
    }

    /**
     * 修改公司回收商合作关联
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "公司回收商合作关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody CompanyRecoverInfoBo bo)
    {
        return toAjax(companyRecoverInfoService.updateCompanyRecoverInfo(bo));
    }

    /**
     * 删除公司回收商合作关联
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "公司回收商合作关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(companyRecoverInfoService.deleteCompanyRecoverInfoByIds(ids));
    }
}

